@extends('admin::layouts.master')
@section('content')
    <div class="col-lg-12">
        <div class="card card-table">
            <div class="card-header">用户管理
                <button class="btn btn-primary ml-2">用户列表</button>
                <button class="btn btn-primary" data-toggle="modal" data-target="#add">添加用户</button>
                @component('components.modal',['title' => '添加用户','url' => '/admin/adminuser','name'=>'add'])
                    <div class="form-group">
                        <label>登录账号</label>
                        <input type="text" required placeholder="请输入后台用户登录账号..." name="name" class="form-control">
                    </div>
                    <div class="form-group">
                        <label>用户昵称</label>
                        <input type="text" required placeholder="请输入后台用户昵称..." name="nickname" class="form-control">
                    </div>
                    <div class="form-group">
                        <label>登录密码</label>
                        <input type="password" required placeholder="请输入后台用户登录密码..." name="password" class="form-control">
                    </div>
                @endcomponent
            </div>
            <div class="card-body">
                <table class="table">
                    <thead>
                    <tr>
                        <th>用户ID</th>
                        <th>用户名</th>
                        <th>用户昵称</th>
                        <th>创建时间</th>
                        <th>操作</th>

                    </tr>
                    </thead>
                    <tbody>
                    @foreach($admins as $admin)
                    <tr>
                        <td>{{$admin['id']}}</td>
                        <td>{{$admin['name']}}</td>
                        <td>{{$admin['nickname']}}</td>
                        <td>{{$admin['created_at']}}</td>
                        <td>
                            <div class="btn-group" role="group" aria-label="Basic example">
                                <button data-toggle="modal" data-target="#useredit{{$admin['id']}}" type="button" class="btn btn-success">编辑</button>
                                @component('components.modal',['title' => '编辑用户','url' => '/admin/adminuser/'.$admin['id'],'name'=>'useredit'.$admin['id'],'id'=>$admin['id'],'method'=>'PATCH'])
                                    <div class="form-group">
                                        <label>用户账号</label>
                                        <input type="text"  value="{{$admin['name']}}" name="name" class="form-control">
                                    </div>
                                    <div class="form-group">
                                        <label>用户昵称</label>
                                        <input type="text" value="{{$admin['nickname']}}" name="nickname" class="form-control">
                                    </div>
                                    <div class="form-group">
                                        <label>登录密码</label>
                                        <input type="password" placeholder="如要修改请填写，否则请勿填写" name="password" class="form-control">
                                    </div>
                                @endcomponent
                                <form action="{{route('adminuser.destroy',$admin['id'])}}" method="post">
                                    @csrf
                                    @method('DELETE')
                                <button type="submit" class="btn btn-danger">删除</button>
                                </form>
                                <a href="{{route('showRole',$admin['id'])}}" class="btn btn-primary">分配角色</a>
                            </div>
                        </td>
                    </tr>
                    @endforeach
                    </tbody>
                </table>

            </div>

        </div>
        {{$admins->links()}}
    </div>
@endsection
